using UnityEngine;

namespace CinemaDirector
{
	public abstract class TrackGroup : MonoBehaviour
	{
		[SerializeField]
		private int ordinal = -1;

		protected Cutscene cutscene;

		public Cutscene Cutscene
		{
			get
			{
				if (cutscene != null && Application.isPlaying)
				{
					return cutscene;
				}
				if (base.transform.parent != null)
				{
					cutscene = base.transform.parent.GetComponent<Cutscene>();
				}
				return cutscene;
			}
		}

		public int Ordinal
		{
			get
			{
				return ordinal;
			}
			set
			{
				ordinal = value;
			}
		}

		public virtual void Initialize(Cutscene cutscrene)
		{
			cutscene = cutscene;
			TimelineTrack[] tracks = GetTracks();
			foreach (TimelineTrack timelineTrack in tracks)
			{
				timelineTrack.Initialize();
			}
		}

		public virtual void UpdateTrackGroup(float time, float deltaTime)
		{
			TimelineTrack[] tracks = GetTracks();
			foreach (TimelineTrack timelineTrack in tracks)
			{
				timelineTrack.UpdateTrack(time, deltaTime);
			}
		}

		public virtual void Pause()
		{
			TimelineTrack[] tracks = GetTracks();
			foreach (TimelineTrack timelineTrack in tracks)
			{
				timelineTrack.Pause();
			}
		}

		public virtual void Stop()
		{
			TimelineTrack[] tracks = GetTracks();
			foreach (TimelineTrack timelineTrack in tracks)
			{
				timelineTrack.Stop();
			}
		}

		public virtual void Resume()
		{
			TimelineTrack[] tracks = GetTracks();
			foreach (TimelineTrack timelineTrack in tracks)
			{
				timelineTrack.Resume();
			}
		}

		public virtual void SetRunningTime(float time)
		{
			TimelineTrack[] tracks = GetTracks();
			foreach (TimelineTrack timelineTrack in tracks)
			{
				timelineTrack.SetTime(time);
			}
		}

		public abstract TimelineTrack[] GetTracks();
	}
}
